package com.share.finance.risk.common.enums;

import lombok.Getter;

import java.util.Optional;

@Getter
public enum FileTypeEnum {
    PERSON_AUTHORIZATION_FILE("person_authorization_file", "个人授权书"),
    ID_CARD_FRONT("id_card_front", "身份证正面图片"),

    ID_CARD_BACK("id_card_back", "身份证反面图片");

    //编码
    public String type;

    //主题名字
    public String name;


    FileTypeEnum(final String type, final String name) {
        this.type = type;
        this.name = name;
    }

    public static FileTypeEnum toEnum(final String type) {
        for (final FileTypeEnum tag : FileTypeEnum.values()) {
            if (tag.type.equals(type)) {
                return tag;
            }
        }
        return null;
    }

    public static String toName(final String code) {
        return Optional.ofNullable(toEnum(code)).map(item -> item.name).orElse(null);
    }
}
